cmake_minimum_required(VERSION 2.8.3)

Project(Torque2D)

# Set required paths
set(BASE_OUTPUT_DIR ${CMAKE_BINARY_DIR})
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${PROJECT_SOURCE_DIR}/../cmake-modules")

# Add modules
INCLUDE(CheckCCompilerFlag)
INCLUDE(CopyFiles)
INCLUDE(CMakeParseArguments)

# Add assets script
add_subdirectory(assets)

INCLUDE_DIRECTORIES(
	../../source
    ../../lib/zlib
    ../../lib/lpng
    ../../lib/ljpeg
    ../../source/persistence/rapidjson/include
    ../../source/testing/googleTest
    ../../source/testing/googleTest/include
)

ADD_DEFINITIONS(-DEMSCRIPTEN=1)
ADD_DEFINITIONS(-DUNICODE=1)
ADD_DEFINITIONS(-w)

SET(T2D_SRCS
    ../../lib/lpng/png.c
    ../../lib/lpng/pngerror.c
    ../../lib/lpng/pngget.c
    ../../lib/lpng/pngmem.c
    ../../lib/lpng/pngpread.c
    ../../lib/lpng/pngread.c
    ../../lib/lpng/pngrio.c
    ../../lib/lpng/pngrtran.c
    ../../lib/lpng/pngrutil.c
    ../../lib/lpng/pngset.c
    ../../lib/lpng/pngtrans.c
    ../../lib/lpng/pngwio.c
    ../../lib/lpng/pngwrite.c
    ../../lib/lpng/pngwtran.c
    ../../lib/lpng/pngwutil.c
    ../../lib/zlib/adler32.c
    ../../lib/zlib/crc32.c
    ../../lib/zlib/compress.c
    ../../lib/zlib/deflate.c
    ../../lib/zlib/infback.c
    ../../lib/zlib/inffast.c
    ../../lib/zlib/inflate.c
    ../../lib/zlib/inftrees.c
    ../../lib/zlib/trees.c
    ../../lib/zlib/uncompr.c
    ../../lib/zlib/zutil.c
    ../../lib/ljpeg/jdapistd.c
    ../../lib/ljpeg/jdmaster.c
    ../../lib/ljpeg/jdapimin.c
    ../../lib/ljpeg/jcapimin.c
    ../../lib/ljpeg/jdmerge.c
    ../../lib/ljpeg/jdatasrc.c
    ../../lib/ljpeg/jdatadst.c
    ../../lib/ljpeg/jdcoefct.c
    ../../lib/ljpeg/jdcolor.c
    ../../lib/ljpeg/jddctmgr.c
    ../../lib/ljpeg/jdhuff.c
    ../../lib/ljpeg/jdinput.c
    ../../lib/ljpeg/jdmainct.c
    ../../lib/ljpeg/jdmarker.c
    ../../lib/ljpeg/jdpostct.c
    ../../lib/ljpeg/jdsample.c
    ../../lib/ljpeg/jdtrans.c
    ../../lib/ljpeg/jerror.c
    ../../lib/ljpeg/jidctflt.c
    ../../lib/ljpeg/jidctfst.c
    ../../lib/ljpeg/jidctint.c
    ../../lib/ljpeg/jmemmgr.c
    ../../lib/ljpeg/jutils.c
    ../../lib/ljpeg/jmemnobs.c
    ../../lib/ljpeg/jquant1.c
    ../../lib/ljpeg/jquant2.c
    ../../lib/ljpeg/jcomapi.c
    ../../lib/ljpeg/jcmarker.c
    ../../lib/ljpeg/jcapistd.c
    ../../lib/ljpeg/jcparam.c
    ../../lib/ljpeg/jcinit.c
    ../../lib/ljpeg/jcdctmgr.c
    ../../lib/ljpeg/jccoefct.c
    ../../lib/ljpeg/jcmainct.c
    ../../lib/ljpeg/jfdctflt.c
    ../../lib/ljpeg/jfdctint.c
    ../../lib/ljpeg/jfdctfst.c
    ../../lib/ljpeg/jchuff.c
    ../../lib/ljpeg/jcsample.c
    ../../lib/ljpeg/jcmaster.c
    ../../lib/ljpeg/jccolor.c
    ../../lib/ljpeg/jcprepct.c
    ../../lib/ljpeg/jdphuff.c
    ../../lib/ljpeg/jcphuff.c
    ../../lib/ljpeg/jidctred.c
    ../../source/2d/scene/SceneRenderFactories.cpp
	../../source/2d/scene/SceneRenderQueue.cpp
	../../source/Box2D/Collision/b2BroadPhase.cpp
	../../source/Box2D/Collision/b2CollideCircle.cpp
	../../source/Box2D/Collision/b2CollideEdge.cpp
	../../source/Box2D/Collision/b2CollidePolygon.cpp
	../../source/Box2D/Collision/b2Collision.cpp
	../../source/Box2D/Collision/b2Distance.cpp
	../../source/Box2D/Collision/b2DynamicTree.cpp
	../../source/Box2D/Collision/b2TimeOfImpact.cpp
	../../source/Box2D/Collision/Shapes/b2ChainShape.cpp
	../../source/Box2D/Collision/Shapes/b2CircleShape.cpp
	../../source/Box2D/Collision/Shapes/b2EdgeShape.cpp
	../../source/Box2D/Collision/Shapes/b2PolygonShape.cpp
	../../source/Box2D/Common/b2BlockAllocator.cpp
	../../source/Box2D/Common/b2Draw.cpp
	../../source/Box2D/Common/b2Math.cpp
	../../source/Box2D/Common/b2Settings.cpp
	../../source/Box2D/Common/b2StackAllocator.cpp
	../../source/Box2D/Common/b2Timer.cpp
	../../source/Box2D/Dynamics/b2Body.cpp
	../../source/Box2D/Dynamics/b2ContactManager.cpp
	../../source/Box2D/Dynamics/b2Fixture.cpp
	../../source/Box2D/Dynamics/b2Island.cpp
	../../source/Box2D/Dynamics/b2World.cpp
	../../source/Box2D/Dynamics/b2WorldCallbacks.cpp
	../../source/Box2D/Dynamics/Contacts/b2ChainAndCircleContact.cpp
	../../source/Box2D/Dynamics/Contacts/b2ChainAndPolygonContact.cpp
	../../source/Box2D/Dynamics/Contacts/b2CircleContact.cpp
	../../source/Box2D/Dynamics/Contacts/b2Contact.cpp
	../../source/Box2D/Dynamics/Contacts/b2ContactSolver.cpp
	../../source/Box2D/Dynamics/Contacts/b2EdgeAndCircleContact.cpp
	../../source/Box2D/Dynamics/Contacts/b2EdgeAndPolygonContact.cpp
	../../source/Box2D/Dynamics/Contacts/b2PolygonAndCircleContact.cpp
	../../source/Box2D/Dynamics/Contacts/b2PolygonContact.cpp
	../../source/Box2D/Dynamics/Joints/b2DistanceJoint.cpp
	../../source/Box2D/Dynamics/Joints/b2FrictionJoint.cpp
	../../source/Box2D/Dynamics/Joints/b2GearJoint.cpp
	../../source/Box2D/Dynamics/Joints/b2Joint.cpp
	../../source/Box2D/Dynamics/Joints/b2MotorJoint.cpp
	../../source/Box2D/Dynamics/Joints/b2MouseJoint.cpp
	../../source/Box2D/Dynamics/Joints/b2PrismaticJoint.cpp
	../../source/Box2D/Dynamics/Joints/b2PulleyJoint.cpp
	../../source/Box2D/Dynamics/Joints/b2RevoluteJoint.cpp
	../../source/Box2D/Dynamics/Joints/b2RopeJoint.cpp
	../../source/Box2D/Dynamics/Joints/b2WeldJoint.cpp
	../../source/Box2D/Dynamics/Joints/b2WheelJoint.cpp
	../../source/Box2D/Rope/b2Rope.cpp
	../../source/collection/nameTags.cpp
	../../source/component/behaviors/behaviorComponent.cpp
	../../source/component/behaviors/behaviorInstance.cpp
	../../source/component/behaviors/behaviorTemplate.cpp
	../../source/component/dynamicConsoleMethodComponent.cpp
	../../source/component/simComponent.cpp
	../../source/delegates/delegateSignal.cpp
	../../source/graphics/PNGImage.cpp
	../../source/math/rectClipper.cpp
	../../source/persistence/SimXMLDocument.cpp
	../../source/persistence/tinyXML/tinystr.cpp
	../../source/persistence/tinyXML/tinyxml.cpp
	../../source/persistence/tinyXML/tinyxmlerror.cpp
	../../source/persistence/tinyXML/tinyxmlparser.cpp
	../../source/platform/nativeDialogs/msgBox.cpp
	../../source/sim/simSerialize.cpp
	../../source/string/stringUnit.cpp
	../../source/2d/assets/AnimationAsset.cc
	../../source/2d/assets/ImageAsset.cc
	../../source/2d/assets/ParticleAsset.cc
	../../source/2d/assets/ParticleAssetEmitter.cc
	../../source/2d/assets/ParticleAssetField.cc
	../../source/2d/assets/ParticleAssetFieldCollection.cc
	../../source/2d/assets/SkeletonAsset.cc
	../../source/2d/assets/FontAsset.cc
	../../source/2d/controllers/AmbientForceController.cc
	../../source/2d/controllers/BuoyancyController.cc
	../../source/2d/controllers/core/GroupedSceneController.cc
	../../source/2d/controllers/core/PickingSceneController.cc
	../../source/2d/controllers/PointForceController.cc
	../../source/2d/core/BatchRender.cc
	../../source/2d/core/CoreMath.cc
	../../source/2d/core/ImageFrameProvider.cc
	../../source/2d/core/ImageFrameProviderCore.cc
	../../source/2d/core/ParticleSystem.cc
	../../source/2d/core/RenderProxy.cc
	../../source/2d/core/SpriteBase.cc
	../../source/2d/core/SpriteBatch.cc
	../../source/2d/core/SpriteBatchItem.cc
	../../source/2d/core/SpriteBatchQuery.cc
	../../source/2d/core/Utility.cc
	../../source/2d/core/Vector2.cc
	../../source/2d/experimental/composites/WaveComposite.cc
	../../source/2d/gui/guiImageButtonCtrl.cc
	../../source/2d/gui/guiSceneObjectCtrl.cc
	../../source/2d/gui/guiSpriteCtrl.cc
	../../source/2d/gui/SceneWindow.cc
	../../source/2d/scene/ContactFilter.cc
	../../source/2d/scene/DebugDraw.cc
	../../source/2d/scene/Scene.cc
	../../source/2d/scene/WorldQuery.cc
	../../source/2d/sceneobject/CompositeSprite.cc
	../../source/2d/sceneobject/ImageFont.cc
	../../source/2d/sceneobject/ParticlePlayer.cc
	../../source/2d/sceneobject/SceneObject.cc
	../../source/2d/sceneobject/SceneObjectList.cc
	../../source/2d/sceneobject/SceneObjectSet.cc
	../../source/2d/sceneobject/Scroller.cc
	../../source/2d/sceneobject/ShapeVector.cc
	../../source/2d/sceneobject/SkeletonObject.cc
	../../source/2d/sceneobject/Sprite.cc
	../../source/2d/sceneobject/Trigger.cc
	../../source/algorithm/crc.cc
	../../source/algorithm/hashFunction.cc
	../../source/assets/assetBase.cc
	../../source/assets/assetFieldTypes.cc
	../../source/assets/assetManager.cc
	../../source/assets/assetQuery.cc
	../../source/assets/assetTagsManifest.cc
	../../source/assets/declaredAssets.cc
	../../source/assets/referencedAssets.cc
	../../source/audio/audio.cc
	../../source/audio/audio_ScriptBinding.cc
	../../source/audio/AudioAsset.cc
	../../source/audio/audioBuffer.cc
	../../source/audio/audioDataBlock.cc
	../../source/audio/audioStreamSourceFactory.cc
	../../source/audio/wavStreamSource.cc
	../../source/audio/audioDescriptions.cc
	../../source/audio/vorbisStreamSource.cc
	../../source/bitmapFont/BitmapFont.cc
	../../source/bitmapFont/BitmapFontCharacter.cc
	../../source/collection/bitTables.cc
	../../source/collection/hashTable.cc
	../../source/collection/undo.cc
	../../source/collection/vector.cc
	../../source/console/astAlloc.cc
	../../source/console/astNodes.cc
	../../source/console/cmdgram.cc
	../../source/console/CMDscan.cc
	../../source/console/codeBlock.cc
	../../source/console/compiledEval.cc
	../../source/console/compiler.cc
	../../source/console/console.cc
	../../source/console/consoleBaseType.cc
	../../source/console/consoleDictionary.cc
	../../source/console/consoleDoc.cc
	../../source/console/consoleExprEvalState.cc
	../../source/console/consoleFunctions.cc
	../../source/console/consoleLogger.cc
	../../source/console/consoleNamespace.cc
	../../source/console/consoleObject.cc
	../../source/console/consoleParser.cc
	../../source/console/consoleTypes.cc
	../../source/console/ConsoleTypeValidators.cc
	../../source/console/metaScripting_ScriptBinding.cc
	../../source/console/Package.cc
	../../source/debug/profiler.cc
	../../source/debug/remote/RemoteDebugger1.cc
	../../source/debug/remote/RemoteDebuggerBase.cc
	../../source/debug/remote/RemoteDebuggerBridge.cc
	../../source/debug/telnetDebugger.cc
	../../source/game/defaultGame.cc
	../../source/game/gameConnection.cc
	../../source/game/gameInterface.cc
	../../source/game/version.cc
	../../source/graphics/bitmapBmp.cc
	../../source/graphics/bitmapJpeg.cc
	../../source/graphics/bitmapPng.cc
	../../source/graphics/color.cc
	../../source/graphics/dgl.cc
	../../source/graphics/dglMatrix.cc
	../../source/graphics/DynamicTexture.cc
	../../source/graphics/gBitmap.cc
	../../source/graphics/gFont.cc
	../../source/graphics/gPalette.cc
	../../source/graphics/splineUtil.cc
	../../source/graphics/TextureDictionary.cc
	../../source/graphics/TextureHandle.cc
	../../source/graphics/TextureManager.cc
	../../source/gui/buttons/guiButtonCtrl.cc
	../../source/gui/buttons/guiCheckBoxCtrl.cc
	../../source/gui/buttons/guiRadioCtrl.cc
	../../source/gui/containers/guiAutoScrollCtrl.cc
	../../source/gui/containers/guiCtrlArrayCtrl.cc
	../../source/gui/containers/guiDragAndDropCtrl.cc
	../../source/gui/containers/guiDynamicCtrlArrayCtrl.cc
	../../source/gui/containers/guiFormCtrl.cc
	../../source/gui/containers/guiFrameCtrl.cc
	../../source/gui/containers/guiPaneCtrl.cc
	../../source/gui/containers/guiRolloutCtrl.cc
	../../source/gui/containers/guiScrollCtrl.cc
	../../source/gui/containers/guiStackCtrl.cc
	../../source/gui/containers/guiTabBookCtrl.cc
	../../source/gui/containers/guiWindowCtrl.cc
	../../source/gui/editor/guiControlListPopup.cc
	../../source/gui/editor/guiDebugger.cc
	../../source/gui/editor/guiEditCtrl.cc
	../../source/gui/editor/guiFilterCtrl.cc
	../../source/gui/editor/guiGraphCtrl.cc
	../../source/gui/editor/guiImageList.cc
	../../source/gui/editor/guiInspector.cc
	../../source/gui/editor/guiInspectorTypes.cc
	../../source/gui/editor/guiMenuBar.cc
	../../source/gui/editor/guiSeparatorCtrl.cc
	../../source/gui/guiArrayCtrl.cc
	../../source/gui/guiBackgroundCtrl.cc
	../../source/gui/guiBitmapBorderCtrl.cc
	../../source/gui/guiBitmapCtrl.cc
	../../source/gui/guiCanvas.cc
	../../source/gui/guiColorPicker.cc
	../../source/gui/guiConsole.cc
	../../source/gui/guiConsoleEditCtrl.cc
	../../source/gui/guiConsoleTextCtrl.cc
	../../source/gui/guiControl.cc
	../../source/gui/guiDefaultControlRender.cc
	../../source/gui/guiFadeinBitmapCtrl.cc
	../../source/gui/guiInputCtrl.cc
	../../source/gui/guiListBoxCtrl.cc
	../../source/gui/guiMessageVectorCtrl.cc
	../../source/gui/guiMLTextCtrl.cc
	../../source/gui/guiMLTextEditCtrl.cc
	../../source/gui/guiPopUpCtrl.cc
	../../source/gui/guiPopUpCtrlEx.cc
	../../source/gui/guiProgressCtrl.cc
	../../source/gui/guiScriptNotifyControl.cc
	../../source/gui/guiSliderCtrl.cc
	../../source/gui/guiTabPageCtrl.cc
	../../source/gui/guiTextCtrl.cc
	../../source/gui/guiTextEditCtrl.cc
	../../source/gui/guiTextEditSliderCtrl.cc
	../../source/gui/guiTextListCtrl.cc
	../../source/gui/guiTickCtrl.cc
	../../source/gui/guiTypes.cc
	../../source/gui/language/lang.cc
	../../source/gui/messageVector.cc
	../../source/input/actionMap.cc
	../../source/io/bitStream.cc
	../../source/io/bufferStream.cc
	../../source/io/byteBuffer.cpp
	../../source/io/fileObject.cc
	../../source/io/fileStream.cc
	../../source/io/fileStreamObject.cc
	../../source/io/fileSystem_ScriptBinding.cc
	../../source/io/filterStream.cc
	../../source/io/memStream.cc
	../../source/io/nStream.cc
	../../source/io/resizeStream.cc
	../../source/io/resource/resourceDictionary.cc
	../../source/io/resource/resourceManager.cc
	../../source/io/streamObject.cc
	../../source/io/zip/centralDir.cc
	../../source/io/zip/compressor.cc
	../../source/io/zip/deflate.cc
	../../source/io/zip/extraField.cc
	../../source/io/zip/fileHeader.cc
	../../source/io/zip/stored.cc
	../../source/io/zip/zipArchive.cc
	../../source/io/zip/zipCryptStream.cc
	../../source/io/zip/zipObject.cc
	../../source/io/zip/zipSubStream.cc
	../../source/io/zip/zipTempStream.cc
	../../source/math/math_ScriptBinding.cc
	../../source/math/mathTypes.cc
	../../source/math/mathUtils.cc
	../../source/math/mBox.cc
	../../source/math/mMath_C.cc
	../../source/math/mMathAltivec.cc
	../../source/math/mMathAMD.cc
	../../source/math/mMathFn.cc
	../../source/math/mMathSSE.cc
	../../source/math/mMatrix.cc
	../../source/math/mPlaneTransformer.cc
	../../source/math/mQuadPatch.cc
	../../source/math/mQuat.cc
	../../source/math/mRandom.cc
	../../source/math/mSolver.cc
	../../source/math/mSplinePatch.cc
	../../source/memory/dataChunker.cc
	../../source/memory/frameAllocator_ScriptBinding.cc
	../../source/messaging/dispatcher.cc
	../../source/messaging/eventManager.cc
	../../source/messaging/message.cc
	../../source/messaging/messageForwarder.cc
	../../source/messaging/scriptMsgListener.cc
	../../source/module/moduleDefinition.cc
	../../source/module/moduleManager.cc
	../../source/module/moduleMergeDefinition.cc
	../../source/network/connectionProtocol.cc
	../../source/network/connectionStringTable.cc
	../../source/network/httpObject.cc
	../../source/network/netConnection.cc
	../../source/network/netDownload.cc
	../../source/network/netEvent.cc
	../../source/network/netGhost.cc
	../../source/network/netInterface.cc
	../../source/network/netObject.cc
	../../source/network/netStringTable.cc
	../../source/network/netTest.cc
	../../source/network/networkProcessList.cc
	../../source/network/RemoteCommandEvent.cc
	../../source/network/serverQuery.cc
	../../source/network/tcpObject.cc
	../../source/network/telnetConsole.cc
	../../source/persistence/taml/binary/tamlBinaryReader.cc
	../../source/persistence/taml/binary/tamlBinaryWriter.cc
	../../source/persistence/taml/json/tamlJSONParser.cc
	../../source/persistence/taml/json/tamlJSONReader.cc
	../../source/persistence/taml/json/tamlJSONWriter.cc
	../../source/persistence/taml/taml.cc
	../../source/persistence/taml/tamlCustom.cc
	../../source/persistence/taml/tamlWriteNode.cc
	../../source/persistence/taml/xml/tamlXmlParser.cc
	../../source/persistence/taml/xml/tamlXmlReader.cc
	../../source/persistence/taml/xml/tamlXmlWriter.cc
	../../source/platform/CursorManager.cc
	../../source/platform/menus/popupMenu.cc
	../../source/platform/nativeDialogs/fileDialog.cc
	../../source/platform/platform.cc
	../../source/platform/platformAssert.cc
	../../source/platform/platformCPU.cc
	../../source/platform/platformFileIO.cc
	../../source/platform/platformFont.cc
	../../source/platform/platformMemory.cc
	../../source/platform/platformNetwork_ScriptBinding.cc
	../../source/platform/platformString.cc
	../../source/platform/platformVideo.cc
	../../source/platform/Tickable.cc
	../../source/sim/scriptGroup.cc
	../../source/sim/scriptObject.cc
	../../source/sim/simBase.cc
	../../source/sim/simConsoleEvent.cc
	../../source/sim/simConsoleThreadExecEvent.cc
	../../source/sim/simDatablock.cc
	../../source/sim/simDictionary.cc
	../../source/sim/simFieldDictionary.cc
	../../source/sim/simManager.cc
	../../source/sim/simObject.cc
	../../source/sim/SimObjectList.cc
	../../source/sim/simSet.cc
	../../source/spine/Animation.c
	../../source/spine/AnimationState.c
	../../source/spine/AnimationStateData.c
	../../source/spine/Atlas.c
	../../source/spine/AtlasAttachmentLoader.c
	../../source/spine/Attachment.c
	../../source/spine/AttachmentLoader.c
	../../source/spine/Bone.c
	../../source/spine/BoneData.c
	../../source/spine/BoundingBoxAttachment.c
	../../source/spine/Event.c
	../../source/spine/EventData.c
	../../source/spine/extension.c
	../../source/spine/Json.c
	../../source/spine/RegionAttachment.c
	../../source/spine/Skeleton.c
	../../source/spine/SkeletonBounds.c
	../../source/spine/SkeletonData.c
	../../source/spine/SkeletonJson.c
	../../source/spine/Skin.c
	../../source/spine/Slot.c
	../../source/spine/SlotData.c
	../../source/string/findMatch.cc
	../../source/string/stringBuffer.cc
	../../source/string/stringStack.cc
	../../source/string/stringTable.cc
	../../source/string/unicode.cc
	../../source/platformEmscripten/EmscriptenAlerts.cpp
	../../source/platformEmscripten/EmscriptenAudio.cpp
	../../source/platformEmscripten/EmscriptenConsole.cpp
	../../source/platformEmscripten/EmscriptenCPUInfo.cpp
	../../source/platformEmscripten/EmscriptenDialogs.cpp
	../../source/platformEmscripten/EmscriptenEvents.cpp
	../../source/platformEmscripten/EmscriptenFileio.cpp
	../../source/platformEmscripten/EmscriptenFont.cpp
	../../source/platformEmscripten/EmscriptenGL.cpp
	../../source/platformEmscripten/EmscriptenInput.cpp
	../../source/platformEmscripten/EmscriptenInputManager.cpp
	../../source/platformEmscripten/EmscriptenMath.cpp
	../../source/platformEmscripten/EmscriptenMemory.cpp
	../../source/platformEmscripten/EmscriptenMutex.cpp
	../../source/platformEmscripten/EmscriptenNet.cpp
	../../source/platformEmscripten/EmscriptenOGLVideo.cpp
	../../source/platformEmscripten/EmscriptenOutlineGL.cpp
	../../source/platformEmscripten/EmscriptenPlatform.cpp
	../../source/platformEmscripten/EmscriptenProcessControl.cpp
	../../source/platformEmscripten/EmscriptenSemaphore.cpp
	../../source/platformEmscripten/EmscriptenStrings.cpp
	../../source/platformEmscripten/EmscriptenThread.cpp
	../../source/platformEmscripten/EmscriptenTime.cpp
	../../source/platformEmscripten/EmscriptenWindow.cpp
	../../source/platformEmscripten/main.cpp
	../../source/platformEmscripten/menus/popupMenu.cpp
)

IF(CMAKE_BUILD_TYPE STREQUAL "Debug")
	set(CMAKE_CXX_LINK_FLAGS "${CMAKE_CXX_LINK_FLAGS} --js-library ../../source/platformEmscripten/platform.js --preload-file ${BASE_OUTPUT_DIR}/data@/ -s TOTAL_MEMORY=134217728 -O0 -s LEGACY_GL_EMULATION=1")#" -s TOTAL_MEMORY=134217728)
	set(CMAKE_CXX__FLAGS "${CMAKE_CXX_LINK_FLAGS} -O0")
ELSEIF(CMAKE_BUILD_TYPE STREQUAL "Release")
	set(CMAKE_CXX_LINK_FLAGS "${CMAKE_CXX_LINK_FLAGS} --js-library ../../source/platformEmscripten/platform.js --preload-file ${BASE_OUTPUT_DIR}/data@/ -s TOTAL_MEMORY=134217728 -O2 -s LEGACY_GL_EMULATION=1")#" -s TOTAL_MEMORY=134217728)
	set(CMAKE_CXX__FLAGS "${CMAKE_CXX_LINK_FLAGS} -O2")
ENDIF(CMAKE_BUILD_TYPE STREQUAL "Debug")

ADD_EXECUTABLE(Torque2D.html
${T2D_SRCS})
add_dependencies(Torque2D.html Assets)

#em_link_js_library
